package alibaba.nulldemo.NullObjectPattern.demo01;

import alibaba.nulldemo.NullObjectPattern.Action;
import alibaba.nulldemo.NullObjectPattern.Parser;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

/**
 * @author ChangLiang
 * @date 2020/4/21
 */
public class AppTest {
    
    @Test
    @DisplayName("test not null")
    public void test(){
        Parser parser = ParserFactory.createParser();
        Action action = parser.findAction("do A");
        if (action == null) {
            // do something
        } else {
            action.doSomething();
        }
    }

    @Test
    @DisplayName("test null")
    public void test2(){
        Parser parser = ParserFactory.createParser();
        Action action = parser.findAction("do C");
        if (action == null) {
            // do nothing
        } else {
            action.doSomething();
        }
    }

}
